package com.ruoyi.web.controller.wnjk.app.physical;

import com.alipay.api.AlipayApiException;
import com.alipay.api.internal.util.AlipaySignature;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.uuid.UUID;
import com.ruoyi.system.pay.domain.dto.PayRequestDTO;
import com.ruoyi.system.pay.service.IPayService;
import com.ruoyi.system.wnjk.domain.po.PhysicalOrder;
import com.ruoyi.system.wnjk.service.IPhysicalService;
import com.ruoyi.system.wnjk.service.IWnjkPhysicalExaminationOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import static com.ruoyi.common.core.domain.AjaxResult.success;

@RestController
@RequestMapping("/app/physical/order")
public class PhysicalOrdercontroller {

    @Autowired
    private IPhysicalService physicalService;

    @Autowired
    private IWnjkPhysicalExaminationOrderService physicalExaminationOrderService;

    @Autowired
    private IPayService payService; // 支付服务

    @Value("${alipay.public-key}")
    private String alipayPublicKey;

    /**
     * 获取体检内容（套餐信息）详细信息
     */
    @GetMapping(value = "/detail/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(physicalService.selectWnjkPhysicalExaminationPackageById(id));
    }

    // 获取体检订单列表(根据用户id)
   @GetMapping(value = "/list/{id}")
    public AjaxResult getOrderList(@PathVariable String id){
        Long userId = Long.parseLong(id);
        return success(physicalExaminationOrderService.selectWnjkPhysicalExaminationOrderByUserId(userId));
   }


   // 根据outTradeNo获取体检订单
   @GetMapping("/listByOutTradeNo/{outTradeNo}")
    public AjaxResult getOrderListByOutTradeNo(@PathVariable String outTradeNo){
        PhysicalOrder physicalOrder = physicalExaminationOrderService.selectByOutTradeNo(outTradeNo);
        return success(physicalOrder);
   }


}